"""Example for the Burger's equation"""

# PyHCL imports
from hogs.grids import grid1d as grid
import hogs.solvers.burgers1d as solvers
import hogs.solvers.flux.burgers.flux as flux
from hogs.solvers.time_step_functions import BurgersTimeStep

import numpy

# initialize the grid
g = grid.Grid1D()
g.initialize(xlow=-3, xhigh=3, dx=0.06, nb=2, nvar=1)

# create the solver
solver = solvers.BurgersSolver(tf=2, nvar=1, pfreq=10, grid=g)

# add the flux function
solver.flux_function = flux.WAF()

# set the grid for the flux function
solver.flux_function.set_grid( solver.grid )

# time step function
solver.time_step_function = BurgersTimeStep(g)

# process command line
solver.setup()

q = g.q; x = g.xc

for i, j in enumerate(x):
    if -1 < j < 0:
        q[0][i] = 0.5

solver.solve()
